/*
v 1.6
Simple client Validation Plugin 

- require jquery UI
- by tiger
- update by jack
*/

(function ($) {

    jQuery.fn.Validate = function (settings) {
        var holder = $(this);
        var defaults = {
            charMes: "Please type character only",
            charThMes: "กรุณากรอกอักษรไทยเท่านั้น",
            charEnMes: "Please type a-z character only",
            charIDMes: "Please type a-z,0-9 only",
            numMes: "Please type numberic only",
            symbolMes: "Please don't type any symbol",
            emailMes: "Wrong format of e-mail",
            requireMes: "Please complete this filed",
            lengthMes: "Length of this filed not least than ",
            customClass: "customValidate",
            usernameMes: "Invalid Username",
            bibNumbererror: "Invalid bibNumber",
            pleaseSelect: "Please Select",
            validateInt: "Please type integer only ",
            validateDecimalAndDigits : "Please type decimal {0} digits",
            validateDecimal : "Please type decimal only ",
            customReq: null,
            customMes: "This is custom message",
            customType: false,
            inLine: false,
            noDiv: false,
            callBack: false,
            checkAllBy: false,
            checkNow: false,
        }; //removeAble : true, false, 'auto'
        var options = jQuery.extend(defaults, settings);
        $("body").find('div.validateMes').remove(); //remove old

        if(options.checkNow == true){
            options.checkAllBy = false; 
        }else{
            //checkNow = false
            $(this).find(".validate").each(function () {
                //
                $(this).unbind("focus").unbind("blur").unbind("keyup");

                //
                var notAccept = null;
                var Accept = null;
                var MES;
                if ($(this).hasClass("char")) {
                    notAccept = /([0-9])|([\`\~\!\@\#\%\&\+\-\=\^\.\,\_\$\*\?\{\}\<\>\/\\\|\[\]\(\)\"\'\:\;])/; //char
                    MES = options.charMes;
                }
                else if ($(this).hasClass("charID")) {
                    notAccept = /([ก-ฮะ-แ])|([\`\~\!\#\%\&\+\=\^\ \,\$\?\{\}\<\>\/\\\|\[\]\(\)\"\'\:\;])/; //char
                    MES = options.charIDMes;
                } else if ($(this).hasClass("usernameChar")) {
                    notAccept = /([ก-ฮะ-แ])|([\`\~\!\@\#\%\&\+\=\^\ \,\$\*\?\{\}\<\>\/\\\|\[\]\(\)\"\'\:\;])/; //char
                    MES = options.usernameMes;
                }
                else if ($(this).hasClass("charTH")) {
                    notAccept = /[A-z0-9]|^\.|([\`\~\!\@\#\%\&\+\-\=\^\,\_\$\*\?\{\}\<\>\/\\\|\[\]\(\)\"\'\:\;])|((\.\d*){2,})|\s/;
                    MES = options.charThMes;
                } else if ($(this).hasClass("charEN")) {
                    notAccept = /[ก-ฮะ-แ0-9]|^\.|([\`\~\!\@\#\%\&\+\-\=\^\,\_\$\*\?\{\}\<\>\/\\\|\[\]\(\)\"\'\:\;])|((\.\d*){2,})|\s/;
                    MES = options.charEnMes;
                } else if ($(this).hasClass("number")) {
                    notAccept = /\D/;
                    MES = options.numMes;
                } else if ($(this).hasClass("symbol")) {
                    notAccept = /[\`\~\!\@\#\%\&\+\-\=\^\.\,\_\$\*\?\{\}\<\>\/\\\|\[\]\(\)\"\'\:\;]/; //symbol
                    MES = options.symbolMes;
                } else if ($(this).hasClass("email")) {
                    //notAccept = /^@|@+\.|@$|[\<\>\<\>\\\[\]\(\)\"\'\:\;]+|@[\.\<\>\<\>\\\[\]\(\)\"\'\:\;]+|\.\w{1}$|\w{1}\.$|@\w+$|\s/; //email 
                    Accept = /^[\w-]+(\.[\w-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z]|.[a-zA-Z]+.[a-zA-Z]{2,4})$/;
                    MES = options.emailMes;
                } else if ($(this).hasClass("bibNumber")) {
                    notAccept = /([ก-ฮะ-แA-z])|([\`\~\!\@\#\%\&\+\-\=\^\.\,\_\$\*\?\{\}\<\>\\\|\[\]\(\)\"\'\:\;])/;
                    MES = options.bibNumbererror;
                } else if ($(this).hasClass("validateInt")) {
                    Accept = /^\s*(\+|-)?\d+\s*$/;
                    ///[\+\-0-9]$/;
                    MES = options.validateInt;
                } else if ($(this).hasClass("validateDecimalAndDigits")){
                    var digit = $(this).attr("digitsOfDecimal");
                    Accept = new RegExp("^\\s*(\\+|-)?((\\d+(\\.\\d{1,"+digit+"})?)|(\\.\\d{1,"+digit+"}))\\s*$");
                    var msg = options.validateDecimalAndDigits.replace("{0}",digit);
                    MES = msg;
                
                } else if ($(this).hasClass("validateDecimal")) {
                    Accept = /^\s*(\+|-)?((\d+(\.\d+)?)|(\.\d+))\s*$/;
                    MES = options.validateDecimal;
                } 
                else if ($(this).hasClass(options.customClass)) {
                    //
                    if (options.customType == "accept") {
                        Accept = options.customReq; //custom 
                    } else {
                        notAccept = options.customReq; //custom 
                    }
                    MES = options.customMes;
                }
                //if has value
                if ($(this).val() != "") {
                    if (notAccept != null) {
                        checkNotAccept(GetValue($(this)), notAccept, MES, $(this));
                    } else if (Accept != null) {
                        checkAccept(GetValue($(this)), Accept, MES, $(this));
                    }
                }
                //check on key
                $(this).keyup(function () {
                    if (notAccept != null) {
                        checkNotAccept(GetValue($(this)), notAccept, MES, $(this));
                    } else if (Accept != null) {
                        checkAccept(GetValue($(this)), Accept, MES, $(this));
                    }
                });
                //map to ui-require-field
                $(this).blur(function () {
                    //$(this).next("span.indicator").css({"position":"absolute","top":($(this).offset().top)+4,"left":($(this).offset().left+$(this).width()),"z-index":10});
                    //$(this).next("img.ui-datepicker-trigger").css({"position":"absolute","top":($(this).offset().top),"left":($(this).offset().left+$(this).width()+4),"z-index":10});
                    //
                    if ($(this).hasClass("lengthValidate")) {
                        var max = $(this).attr("maxData");
                        var min = $(this).attr("minData");
                        notAccept = new RegExp("^(?![^~]{" + min + "," + max + "}$).*$");
                        //var re = new RegExp("/^(?![^~]{strmin,strMax}$).*$/", "g");
                        //notAccept = /^(?![^~]{strmin,strMax}$).*$/  //lengthValidate   ?! ไม่เท่ากับ
                        MES = "lengthValidate " + min + "-" + max;
                    }
                    if (notAccept != null) {
                        checkNotAccept(GetValue($(this)), notAccept, MES, $(this));
                    } else if (Accept != null) {
                        checkAccept(GetValue($(this)), Accept, MES, $(this));
                    }
                    //$(this).next("div.validateMes").remove();"width":$(obj).width()-6

                    if ($(this).hasClass("ui-require-field")) {
                        //                    if (!$(this).val()) {
                        //                        $(this).removeAttr("title").nextAll("div.validateMes:first").remove().end().after('<div class="validateMes ui-state-highlight ui-helper-clearfix" style="padding:4px;min-width:' + ($(this).width() + 20) + 'px"><div class="ui-icon ui-icon-info" style="float:left"></div><div class="valMes" style="float:left">' + options.requireMes + '</div></div>');
                        //                    }
                        if (!$(this).val() && $(this).attr("readonly") != "readonly") {
                            //ถ้าเป็น text box
                            if ($(this).is("Input")) {

                                $(this).removeAttr("title").nextAll("div.validateMes:first").remove().end()
                                .after('<div class="validateMes ui-state-highlight ui-helper-clearfix"  style="padding:4px;min-width:' + ($(this).width() + 20) + 'px;left:'+$(this).position().left+'px;"><div class="ui-icon ui-icon-info" style="float:left"></div><div class="valMes" style="float:left">' + options.requireMes + '</div><span class="btnCloseValidateMes">x<span></div>');

                            }
                            else if ($(this).is("select")) //ถ้าเป็น dropdrown
                            {
                                $(this).removeAttr("title").nextAll("div.validateMes:first").remove().end()
                                .after('<div class="validateMes ui-state-highlight ui-helper-clearfix"  style="padding:4px;min-width:' + ($(this).width() + 20) + 'px;position: absolute;opacity:0.9;left:'+$(this).position().left+'px;"><div class="ui-icon ui-icon-info" style="float:left"></div><div class="valMes" style="float:left">' + options.pleaseSelect + '</div><span class="btnCloseValidateMes">x<span></div>');
                            }
                            else if ($(this).is("textarea")) //ถ้าเป็น dropdrown
                            {
                                $(this).removeAttr("title").nextAll("div.validateMes:first").remove().end()
                                .after('<div class="validateMes ui-state-highlight ui-helper-clearfix"  style="padding:4px;min-width:' + ($(this).width() + 20) + 'px;left:'+$(this).position().left+'px;"><div class="ui-icon ui-icon-info" style="float:left"></div><div class="valMes" style="float:left">' + options.requireMes + '</div><span class="btnCloseValidateMes">x<span></div>');
                            }
                        }
                        CloseValidateMes();
                    }

                    //
                    if (options.inLine) { fixInline($(this)) } else if (options.noDiv && $(this).hasClass("ui-require-field")) { fixNoDiv($(this), options.requireMes) };
                    $(this).nextAll("span.indicator:first").insertAfter($(this));
                    $(this).nextAll("img.ui-datepicker-trigger:first").insertAfter($(this));
                }).focus(function () {
                    //alert("focus")
                    $(this).removeAttr("title").nextAll("div.validateMes:first").remove();
                });
            });
        }//checkNow = false
        
        //check not accept
        function checkNotAccept(thisText, notAccept, MES, obj) {
            if (notAccept.test(thisText)) {
                if (options.callBack) { eval(options.callBack) } //call back function
                $(obj).removeAttr("title").nextAll("div.validateMes:first").remove().end().after('<div class="validateMes ui-state-highlight ui-helper-clearfix"  style="padding:4px;min-width:' + ($(obj).width() + 20) + 'px;left:'+$(obj).position().left+'px;"><div class="ui-icon ui-icon-info" style="float:left"></div><div class="valMes" style="float:left">' + MES + '</div><span class="btnCloseValidateMes">x<span></div>');
                if (options.inLine) { fixInline(obj) } else if (options.noDiv) { fixNoDiv(obj, MES) };
                //
                $(obj).nextAll("span.indicator:first").insertAfter($(obj));
                $(obj).nextAll("img.ui-datepicker-trigger:first").insertAfter($(obj));
                CloseValidateMes();
                return false;
            } else {
                //check lenght
                if ($(obj).attr("minlength") && thisText.length < $(obj).attr("minlength") && thisText != "") {
                    $(obj).removeAttr("title").nextAll("div.validateMes:first").remove().end().after('<div class="validateMes ui-state-highlight ui-helper-clearfix"  style="padding:4px;min-width:' + ($(obj).width() + 20) + 'px;left:'+$(obj).position().left+'px;"><div class="ui-icon ui-icon-info" style="float:left"></div><div class="valMes" style="float:left">' + options.lengthMes + $(obj).attr("minlength") + '</div><span class="btnCloseValidateMes">x<span></div>');
                    if (options.inLine) { fixInline(obj) } else if (options.noDiv) { fixNoDiv(obj, (options.lengthMes + $(obj).attr("minlength"))) };
                    //
                    $(obj).nextAll("span.indicator:first").insertAfter($(obj));
                    $(obj).nextAll("img.ui-datepicker-trigger:first").insertAfter($(obj));
                    CloseValidateMes();
                } else {
                    $(obj).removeAttr("title").nextAll("div.validateMes:first").remove();
                }
            }
            //
        }
        //check accept
        function checkAccept(thisText, Accept, MES, obj) {
            //
            if (!Accept.test(thisText) && thisText != "") {
                if (options.callBack) { eval(options.callBack) } //call back function
                $(obj).removeAttr("title").nextAll("div.validateMes:first").remove().end().after('<div class="validateMes ui-state-highlight ui-helper-clearfix"  style="padding:4px;min-width:' + ($(obj).width() + 20) + 'px;"><div class="ui-icon ui-icon-info" style="float:left"></div><div class="valMes" style="float:left">' + MES + '</div><span class="btnCloseValidateMes">x<span></div>');
                if (options.inLine) { fixInline(obj) } else if (options.noDiv) { fixNoDiv(obj, MES) };
                //
                $(obj).nextAll("span.indicator:first").insertAfter($(obj));
                $(obj).nextAll("img.ui-datepicker-trigger:first").insertAfter($(obj));
                CloseValidateMes();
                return false;
            } else {
                //check lenght
                if ($(obj).attr("minlength") && thisText.length < $(obj).attr("minlength")) {
                    $(obj).removeAttr("title").nextAll("div.validateMes:first").remove().end().after('<div class="validateMes ui-state-highlight ui-helper-clearfix"  style="padding:4px;min-width:' + ($(obj).width() + 20) + 'px;"><div class="ui-icon ui-icon-info" style="float:left"></div><div class="valMes" style="float:left">' + options.lengthMes + $(obj).attr("minlength") + '</div><span class="btnCloseValidateMes">x<span></div>');
                    if (options.inLine) { fixInline(obj) } else if (options.noDiv) { fixNoDiv(obj, (options.lengthMes + $(obj).attr("minlength"))) };
                    //
                    $(obj).nextAll("span.indicator:first").insertAfter($(obj));
                    $(obj).nextAll("img.ui-datepicker-trigger:first").insertAfter($(obj));
                    CloseValidateMes();
                } else {
                    $(obj).removeAttr("title").nextAll("div.validateMes:first").remove();
                }
            }

        }
        //check if inline display
        function fixInline(obj) {
            $(obj).nextAll("div.validateMes:first").css({ "position": "absolute", "top": ($(obj).position().top + $(obj).height() + 4), "left": ($(obj).position().left), "width": $(obj).width() + 20, "z-index": 10 }).addClass("ui-corner-bottom");
        }
        //check if no div display
        function fixNoDiv(obj, MES) {
            if ($(obj).nextAll("div.validateMes:first").size()) {
                $(obj).css({ "background-color": "#FFD8E0" }).attr("title", MES).nextAll("div.validateMes:first").hide();
            }
        }
        //-----------
        if (options.checkAllBy != "" && options.checkAllBy != false) {
            var checkAt = $(this);
            $(options.checkAllBy).click(function () {
                ValidateMethod(checkAt);
            });
        }else if(options.checkNow){
            
            ValidateMethod(holder);
        }
        //------------
        function ValidateMethod(checkAt)
        {
            $("body").find('div.validateMes').remove();
                //
                $(checkAt).find(".validate").not(".prototype").each(function () {
                    var notAccept = null;
                    var Accept = null;
                    var MES;
                    if ($(this).hasClass("lengthValidate")) {
                        var max = $(this).attr("maxData");
                        var min = $(this).attr("minData");
                        notAccept = new RegExp("^(?![^~]{" + min + "," + max + "}$).*$");
                        //var re = new RegExp("/^(?![^~]{strmin,strMax}$).*$/", "g");
                        //notAccept = /^(?![^~]{strmin,strMax}$).*$/  //lengthValidate   ?! ไม่เท่ากับ
                        MES = "lengthValidate " + min + "-" + max;
                    } else if ($(this).hasClass("char")) {
                        notAccept = /([0-9])|([\`\~\!\@\#\%\&\+\-\=\^\.\,\_\$\*\?\{\}\<\>\/\\\|\[\]\(\)\"\'\:\;])/; //char
                        MES = options.charMes;
                    } else if ($(this).hasClass("charTH")) {
                        notAccept = /[A-z0-9]|^\.|([\`\~\!\@\#\%\&\+\-\=\^\,\_\$\*\?\{\}\<\>\/\\\|\[\]\(\)\"\'\:\;])|((\.\d*){2,})|\s/;
                        MES = options.charThMes;
                    } else if ($(this).hasClass("usernameChar")) {
                        notAccept = /([ก-ฮะ-แ])|([\`\~\!\@\#\%\&\+\=\^\ \,\$\*\?\{\}\<\>\/\\\|\[\]\(\)\"\'\:\;])/; //char
                        MES = options.usernameMes;
                    } else if ($(this).hasClass("charEN")) {
                        notAccept = /[ก-ฮะ-แ0-9]|^\.|([\`\~\!\@\#\%\&\+\-\=\^\,\_\$\*\?\{\}\<\>\/\\\|\[\]\(\)\"\'\:\;])|((\.\d*){2,})|\s/;
                        MES = options.charEnMes;
                    } else if ($(this).hasClass("number")) {
                        notAccept = /\D/;
                        MES = options.numMes;
                    } else if ($(this).hasClass("symbol")) {
                        notAccept = /[\`\~\!\@\#\%\&\+\-\=\^\.\,\_\$\*\?\{\}\<\>\/\\\|\[\]\(\)\"\'\:\;]/; //symbol
                        MES = options.symbolMes;
                    } else if ($(this).hasClass("validateInt")) {
                        Accept = /^\s*(\+|-)?\d+\s*$/;
                        ///[\+\-0-9]$/;
                        MES = options.validateInt;
                    } else if ($(this).hasClass("validateDecimalAndDigits")){
                        var digit = $(this).attr("digitsOfDecimal");
                        Accept = new RegExp("^\\s*(\\+|-)?((\\d+(\\.\\d{1,"+digit+"})?)|(\\.\\d{1,"+digit+"}))\\s*$");
                        var msg = options.validateDecimalAndDigits.replace("{0}",digit);
                        MES = msg;
                    }else if ($(this).hasClass("validateDecimal")) {
                        Accept = /^\s*(\+|-)?((\d+(\.\d+)?)|(\.\d+))\s*$/;
                        MES = options.validateDecimal;
                    }  
                    else if ($(this).hasClass("email")) {
                        //notAccept = /^@|@+\.|@$|[\<\>\<\>\\\[\]\(\)\"\'\:\;]+|@[\.\<\>\<\>\\\[\]\(\)\"\'\:\;]+|\.\w{1}$|\w{1}\.$|@\w+$|\s/; //email 
                        Accept = /^[\w-]+(\.[\w-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z]|.[a-zA-Z]+.[a-zA-Z]{2,4})$/;
                        MES = options.emailMes;
                    } else if ($(this).hasClass(options.customClass)) {
                        //
                        if (options.customType == "accept") {
                            Accept = options.customReq; //custom 
                        } else {
                            notAccept = options.customReq; //custom 
                        }
                        MES = options.customMes;
                    }
                    //
                    if (notAccept != null) {
                        checkNotAccept(GetValue($(this)), notAccept, MES, $(this));
                    } else if (Accept != null) {
                        checkAccept(GetValue($(this)), Accept, MES, $(this));
                    }
                    
                    var nextRows = ValidateMaxMinDecimal($(this),options);
                    if(nextRows == true) {return false;}

                    //$(this).next("div.validateMes").remove();
                    if ($(this).hasClass("ui-require-field")) {
                        //+++ตรวจสอบ tokenInput
                        nextRows = ValidateTokenInput($(this),options);
                        if(nextRows == true) {return false;}
                        
                        //--ตรวจสอบ tokenInput
                        if (!$(this).val()) {
                            //ถ้าเป็น text box
                            if ($(this).is("Input")) {
                                $(this).removeAttr("title").nextAll("div.validateMes:first").remove().end()
                                .after('<div class="validateMes ui-state-highlight ui-helper-clearfix"  style="padding:4px;min-width:' + ($(this).width() + 20) + 'px;left:'+$(this).position().left+'px;"><div class="ui-icon ui-icon-info" style="float:left"></div><div class="valMes" style="float:left">' + options.requireMes + '</div><span class="btnCloseValidateMes">x<span></div>');
                            }
                            else if ($(this).is("select")) //ถ้าเป็น dropdrown
                            {
                                $(this).removeAttr("title").nextAll("div.validateMes:first").remove().end()
                                .after('<div class="validateMes ui-state-highlight ui-helper-clearfix"  style="padding:4px;min-width:' + ($(this).width() + 20) + 'px;left:'+$(this).position().left+'px;"><div class="ui-icon ui-icon-info" style="float:left"></div><div class="valMes" style="float:left">' + options.pleaseSelect + '</div><span class="btnCloseValidateMes">x<span></div>');
                            }
                            else if ($(this).is("textarea")) //ถ้าเป็น dropdrown
                            {
                                $(this).removeAttr("title").nextAll("div.validateMes:first").remove().end()
                                .after('<div class="validateMes ui-state-highlight ui-helper-clearfix"  style="padding:4px;min-width:' + ($(this).width() + 20) + 'px;left:'+$(this).position().left+'px;"><div class="ui-icon ui-icon-info" style="float:left"></div><div class="valMes" style="float:left">' + options.requireMes + '</div><span class="btnCloseValidateMes">x<span></div>');
                            } 
                            else if($(this).hasClass("multiSelect"))
                            {
                                if($(this).find(".captionMSHead").val() == ""){
                                    $(this).nextAll("div.validateMes:first").remove().end()
                                    .after('<div class="validateMes ui-state-highlight ui-helper-clearfix"  style="padding:4px;min-width:' 
                                    + ($(this).width() + 20) + 'px;left:'+$(this).position().left
                                    +'px;top:'+($(this).position().top+28)+'px;"><div class="ui-icon ui-icon-info" style="float:left"></div><div class="valMes" style="float:left">Please Select</div><span class="btnCloseValidateMes">x<span></div>');
                                }
                            }
                            
                            
                        }
                    }
                    //
                });
                CloseValidateMes();
                //
        }
        //---------------
        function CloseValidateMes() {
            $(".btnCloseValidateMes").click(function () {
                $(this).parents(".validateMes").remove();
            });
        }
        function GetValue(holder)
        {
            if (holder.is("Input")) {
                return holder.val();
            }
            else if (holder.is("textarea")) 
            {
                return $(holder).val();
            }
        }
        function ValidateTokenInput(holder,options)
        {
            if($(holder).hasClass("ELTokenInput-Section"))
            {
                var result = $(holder).find(".tokenInput").tokenInput("get");
                if(result == "" || result == null){
                    DisplayValidateMes($(holder),options);
                }
                return true;               
            }
            return false;
        }
        function ValidateMaxMinDecimal(holder,options)
        {
            if($(holder).hasClass("jNumeric"))
            {
                var minValide = parseFloat($(holder).attr("minValide"));
                var maxValide = parseFloat($(holder).attr("maxValide"));
                
                if(minValide == undefined || minValide == null || minValide == "" || maxValide == undefined || maxValide== null || maxValide =="" )
                {
                    return false;   
                }
                var result = parseFloat($(holder).jNumeric("get"));
                if(minValide > result ||  maxValide < result)
                {
                    //alert(maxValide +","+ minValide + "," +result);
                    DisplayValidateMes($(holder),options,"Please enter number  "+ minValide + " - "+  (maxValide).formatNumeric(0, '.', ','));
                    return true;
                }          
            }
            return false;
        }


        function DisplayValidateMes(holder,options,errorMes)
        {
            if(errorMes == "" || errorMes == null || errorMes == undefined){errorMes = options.requireMes};
            $(holder).removeAttr("title").nextAll("div.validateMes:first").remove().end()
            .after('<div class="validateMes ui-state-highlight ui-helper-clearfix"  style="padding:4px;min-width:' + ($(holder).width() + 20) 
            + 'px;left:'+$(holder).position().left+'px;"><div class="ui-icon ui-icon-info" style="float:left"></div><div class="valMes" style="float:left">' 
            + errorMes + '</div><span class="btnCloseValidateMes">x<span></div>');
        }
    }

})(jQuery);



(function ($) {
    jQuery.fn.ValidateUI = function (settings) {
        var holder = $(this);
        var defaults = {
            customType: false,
            inLine: false,
            noDiv: false,
            callBack: false,
            checkAllBy: false,
            checkNow: false,
        }; //removeAble : true, false, 'auto'
        var vlds = $('body').data('validateSetting');
        var options = jQuery.extend(defaults, vlds);
        options = jQuery.extend(options,settings);
//        var settings = {
//            charMes: vlds.charMes,
//            charThMes: vlds.charThMes,
//            charEnMes: vlds.charEnMes,
//            numMes: "<%=Html.Encode(Resources.Alert.ValidateNumMes)%>",
//            symbolMes: "<%=Html.Encode(Resources.Alert.ValidateSymbolMes)%>",
//            emailMes: "<%=Html.Encode(Resources.Alert.ValidateEmailMes)%>",
//            requireMes: "<%=Html.Encode(Resources.Alert.ValidateRequireMes)%>",
//            lengthMes: "<%=Html.Encode(Resources.Alert.ValidateLengthMes)%>",
//            charIDMes: "<%=Html.Encode(Resources.Alert.ValidateCharEnMesAndNumberSymbol)%>",
//            customClass: "customValidate",
//            usernameMes: "<%=Html.Encode(Resources.Alert.ValidateCharEnMesAndNumber)%>",
//            bibNumbererror: "<%=Html.Encode(Resources.Alert.ValidatePleaseEnterNumberOrSymbolSlash)%>",
//            customReq: /\w+/,
//            customMes: "<%=Html.Encode(Resources.Alert.ValidateCustomMes)%>",
//            pleaseSelect: "<%=Html.Encode(Resources.Caption.PleaseSelect)%>",
//            customType: false,
//            inLine: false,
//            noDiv: false,
//            callBack: false,
//            checkAllBy: false
//        }; //removeAble : true, false, 'auto'

        $(holder).Validate(options);
    }
})(jQuery);